"""
__author__ = 'berlinyoung'
@File   :email_manage_page.py
@Date   :2022/5/11 0:25
-*- coding: utf-8 -*-
"""
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait

from weixin_web.step1.po.base import Base


class EmailManagePage(Base):

    ele_email_bin = (By.XPATH, '//*[@class="weworktool_index_list clearfix"]/li[6]//div[@class="item_footer"]/a')
    ele_checkbox_choosed = (By.XPATH,'//*[@class="qy_table mbr_leave_list"]//tr[@data-index="0"]/td[(1)]')
    ele_ww_btn_confirm=(By.XPATH,'//*[@ck="confirm"]')

    def goto_email_bin(self):
        self.find_and_click(self.ele_email_bin)
        self.find_and_click(self.ele_checkbox_choosed)
        self.find_and_click(By.XPATH,'//*[@class="qy_btn js_delAccount"]')
        self.driver.switch_to.default_content()
        iframe_path = self.driver.find_element(By.XPATH,'//*[@class="frame_dialog_container"]/iframe[@frameborder="0"]')
        self.driver.switch_to.frame(iframe_path)
        WebDriverWait(self.driver,10).until(expected_conditions.element_to_be_clickable(self.ele_ww_btn_confirm))
        self.find_and_click(self.ele_ww_btn_confirm)
        self.find_and_click(By.XPATH,'//*[@ck="ico_close_cancel"]')
        self.driver.switch_to.default_content()
        r = self.driver.find_element(By.XPATH, '//div[@data-type="exmail"]//iframe[@class="js_qykit_frame"]')
        self.driver.switch_to.frame(r)

        email_list = []
        emails = self.finds(By.XPATH,'//*[@class="text_ellipsis"]')
        for value in emails:
            email_list.append(value.text)
        return email_list